//
//  Health.cpp
//  party-family
//
//  Created by Justin Kurtz on 6/18/11.
//

#include "Health.h"

Health::Health() 
{
   this->maxHealth = 100;
   this->currHealth = 100;
}

Health::Health(int mHealth)
{
   this->maxHealth = mHealth;
   this->currHealth = mHealth;
}

Health::~Health()
{
   
}

int Health::GetHealth()
{
   return currHealth;
}

float Health::GetHealthPercentage()
{
   return currHealth / maxHealth;
}

void Health::SetMaxHealth(int amount)
{
   maxHealth = amount;
   if(currHealth > maxHealth)
      currHealth = maxHealth;
}

void Health::AddHealth(int amount)
{
   currHealth += amount;
   
   if(currHealth > maxHealth)
   {
      // no stashing health for you!
      currHealth = maxHealth;
   }
   else if(currHealth < 0)
   {
      currHealth = 0;
   }
}

void Health::RestoreToMax()
{
   currHealth = maxHealth;
}

void Health::Damage(int amount)
{
   AddHealth(amount * -1);
}

void Health::Kill()
{
   currHealth = 0;
}

bool Health::IsAlive()
{
   return currHealth > 0;
}
